package org.zjvis.datascience.common.dto.kg;

import com.alibaba.fastjson.JSONObject;
import cn.weiguangfu.swagger2.plus.annotation.ApiRequestExclude;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.zjvis.datascience.common.dto.BaseDTO;
import org.zjvis.datascience.common.dto.dataset.DatasetNameStatusDTO;
import org.zjvis.datascience.common.util.DozerUtil;
import org.zjvis.datascience.common.vo.BaseVO;
import org.zjvis.datascience.common.vo.category.DatasetAndCategoryForProjectVO;
import org.zjvis.datascience.common.vo.kg.KnowledgeGraphVO;

import java.time.LocalDateTime;

/**
 * @description 知识图谱数据推送DTO
 * @date 2022-03-28
 */
@Data
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
public class KnowledgeGraphDTO extends BaseDTO {

    private Long id;

    private Long userId;

    private Long projectId;

    private String name;

    @ApiRequestExclude(groups = {BaseVO.Ignore.class})
    @JsonFormat(shape=JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime publishTime;

    private String baseUri;

    private String category;

    private String info;

    public KnowledgeGraphVO view() {
        KnowledgeGraphVO vo = DozerUtil.mapper(this, KnowledgeGraphVO.class);
        vo.setInfo(JSONObject.parseObject(this.getInfo()));
        return vo;
    }

    public KnowledgeGraphDTO(Long userId){
        this.userId = userId;
    }

    /**
     * 为了拼装格式，没有实际用处
     * @return
     */
    public DatasetNameStatusDTO toDatasetNameStatusDTO() {
        return DatasetNameStatusDTO.builder().id(this.getId()).status(0).name(this.getName()).type("kg").build();
    }
}

